package com.sample.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.core.client.GWT;

public class Login extends Composite {
	private static final AppConstants CONSTANTS = GWT.create(AppConstants.class);

	public Login() {
		super();
		
		VerticalPanel verticalPanel = new VerticalPanel();
		initWidget(verticalPanel);
		
		Label lblNewLabel = new Label(CONSTANTS.lblNewLabel_text());
		lblNewLabel.setStyleName("gwt-Label-Login");
		verticalPanel.add(lblNewLabel);
		
		FlexTable flexTable = new FlexTable();
		verticalPanel.add(flexTable);
		
		Label lblUsername = new Label(CONSTANTS.lblUsername_text());
		flexTable.setWidget(0, 0, lblUsername);
		
		final TextBox usr = new TextBox();
		usr.setName("usr");
		flexTable.setWidget(0, 1, usr);
		
		Label lblNewLabel_1 = new Label(CONSTANTS.lblNewLabel_1_text());
		flexTable.setWidget(1, 0, lblNewLabel_1);
		
		final TextBox pwd = new TextBox();
		pwd.setName("pwd");
		flexTable.setWidget(1, 1, pwd);
		
		Button btnNewButton = new Button(CONSTANTS.btnNewButton_html());
		btnNewButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				if (usr.getText().length() == 0 || pwd.getText().length() == 0) {
					Window.alert(CONSTANTS.litMessage()); 
				}
			}
		});
		flexTable.setWidget(2, 1, btnNewButton);

	}

}
